package com.zhiletu.collect.splitword;

import com.zhiletu.collect.util.ParseString;

/**
 *
 * @Title: WordFilter.java
 * @Package com.zhiletu.collect.splitword
 * @Description: 词汇过滤器（以词性、字符长度、字面值为颗粒度执行过滤）
 * @author zhiletu.com
 * @date 2021年3月11日
 * @version V1.0
 */
public class WordFilter implements Comparable<WordFilter> {
	int count = 0; // 频次

	private String wordNature = null; // 词性

	private String wordLength = null; // 词长度

	private String wordName = null; // 字面

	public WordFilter(String wordNature, String name, int count) {
		this.wordNature = wordNature;
		int len = ParseString.nvl(name).length();
		this.wordLength = Integer.toString(len);
		this.wordName = name;
		this.count = count;
	}

	WordFilter(String wordNature, String name) {
		this.wordNature = wordNature;
		int len = ParseString.nvl(name).length();
		this.wordLength = len == 0 ? null : Integer.toString(len);
		this.wordName = name;
	}

	WordFilter(String wordNature) {
		this.wordNature = wordNature;
	}

	public String getWordNature() {
		return wordNature;
	}

	public void setWordNature(String wordNature) {
		this.wordNature = wordNature;
	}

	public String getWordLength() {
		return wordLength;
	}

	public void setWordLength(String wordLength) {
		this.wordLength = wordLength;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public String getWordName() {
		return wordName;
	}

	public void setWordName(String wordName) {
		this.wordName = wordName;
	}

	@Override
	public int compareTo(WordFilter o) {
		if (this.count > o.count) {
			return 1;
		}
		else if (this.count == o.count) {
			return 0;
		}
		else {
			return -1;
		}
	}

	@Override
	public String toString() {

		return "词汇：[" + this.wordName + "] 词性：[" + this.wordNature + "] 长度：[" + this.wordLength + "] 词频：[" + this.count + "]";
	}
}